from fastapi import APIRouter
import time
from datetime import datetime

# 绝对导入
from app.models.schemas import SystemStatus, HealthCheck
from app.services.model_manager import ModelManager
from app.config.settings import settings

router = APIRouter()
model_manager = ModelManager()

# Track startup time for uptime calculation
STARTUP_TIME = time.time()

@router.get("/status", response_model=SystemStatus)
async def system_status():
    """
    Get system status and statistics
    """
    return SystemStatus(
        status="running",
        active_models=model_manager.get_active_models(),
        total_requests=model_manager.get_total_requests(),
        uptime=time.time() - STARTUP_TIME
    )

@router.get("/health", response_model=HealthCheck)
async def health_check():
    """
    Health check endpoint
    """
    return HealthCheck(
        status="healthy",
        timestamp=datetime.now(),
        version=settings.VERSION
    )